package leetcode100;

import java.util.Scanner;

/**
 * @author shkstart
 * @create 2022-12-21-22:55
 */
public class Meme19_1 {
    public static void main(String[] args) {
        int a;
        Scanner in = new Scanner(System.in);
        while ( (a=in.nextInt())!= 0) { // 注意 while 处理多个 case

            int res = getNum(a);
            System.out.println(res);
        }
    }

    public static int getNum(int n) {
        int sum = 0;//总共喝到可乐的瓶数
        while (n != 1) {//瓶子数剩一个时结束
            sum += n / 3;
            n = n % 3 + n / 3;
            if (n == 2) {
                sum++;//剩下两个瓶子，找老板换可乐，喝掉之后送回瓶子
                break;
            }
        }
        return sum;

    }
}
